package com.huiyeji.mail.trigger;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "hsp.mail.trigger")
public class HspMailTriggerProperties {

    /**
     * 需要监控的邮箱服务器地址
     */
    private String host;

    /**
     * 需要监控的邮箱用户名
     */
    private String username;

    /**
     * 需要监控的邮箱密码
     */
    private String password;

    /**
     * 邮箱监控间隔时间，单位分钟
     */
    private int intervalMinutes;

    /**
     * 需要监控的邮箱协议
     */
    private Protocol protocol;

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getIntervalMinutes() {
        return intervalMinutes;
    }

    public void setIntervalMinutes(int intervalMinutes) {
        this.intervalMinutes = intervalMinutes;
    }

    public Protocol getProtocol() {
        return protocol;
    }

    public void setProtocol(Protocol protocol) {
        this.protocol = protocol;
    }

    public static enum Protocol {
        IMAP {
            @Override
            public String getPort() {
                throw new UnsupportedOperationException();
            }

            @Override
            public String getProtocol() {
                throw new UnsupportedOperationException();
            }
        },

        IMAPS {
            @Override
            public String getPort() {
                return "993";
            }

            @Override
            public String getProtocol() {
                return "imaps";
            }
        };


        public abstract String getPort();

        public abstract String getProtocol();
    }
}
